use std::fs;
use std::path::{Path, PathBuf};
use util::{CargoResult, human};
+use util::paths;
/// Iteratively search for `file` in `pwd` and its parents, returning
/// the path of the directory.
-> CargoResult<PathBuf> {
match manifest_path {
Some(path) => {
- let absolute_path = cwd.join(&path);
+ let absolute_path = paths::normalize_path(&cwd.join(&path));
if !absolute_path.ends_with("Cargo.toml") {
bail!("the manifest-path must be a path to a Cargo.toml file")
}
assert_that(p.cargo("build").cwd(p.root().join("bar")), execs().with_status(0));
}
+#[test]
+fn relative_path_for_root_works() {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "foo"
+ version = "0.1.0"
+ authors = []
+
+ [workspace]
+
+ [dependencies]
+ subproj = { path = "./subproj" }
+ "#)
+ .file("src/main.rs", "fn main() {}")
+ .file("subproj/Cargo.toml", r#"
+ [project]
+ name = "subproj"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("subproj/src/main.rs", "fn main() {}");
+ p.build();
+
+ assert_that(p.cargo("build").cwd(p.root())
+ .arg("--manifest-path").arg("./Cargo.toml"),
+ execs().with_status(0));
+
+ assert_that(p.cargo("build").cwd(p.root().join("subproj"))
+ .arg("--manifest-path").arg("../Cargo.toml"),
+ execs().with_status(0));
+}
+
#[test]
fn path_dep_outside_workspace_is_not_member() {
let p = project("foo")